import 'package:fish_redux/fish_redux.dart';

import 'action.dart';
import 'state.dart';

Reducer<RefuseIndoorState> buildReducer() {
  return asReducer(
    <Object, Reducer<RefuseIndoorState>>{
      RefuseIndoorAction.action: _onAction,
      RefuseIndoorAction.setOrderPhoto: _setOrderPhoto,
      RefuseIndoorAction.onSetIndex: _onSetIndex,
      RefuseIndoorAction.onSetSelectReason: _onSetSelectReason,
    },
  );
}

RefuseIndoorState _onAction(RefuseIndoorState state, Action action) {
  final RefuseIndoorState newState = state.clone();
  return newState;
}

RefuseIndoorState _setOrderPhoto(RefuseIndoorState state, Action action) {
  final RefuseIndoorState newState = state.clone();
  newState.orderPhoto.add(action.payload);
  return newState;
}

RefuseIndoorState _onSetIndex(RefuseIndoorState state, Action action) {
  final RefuseIndoorState newState = state.clone()
    ..selectIndex = action.payload;
  return newState;
}

RefuseIndoorState _onSetSelectReason(RefuseIndoorState state, Action action) {
  final RefuseIndoorState newState = state.clone()
    ..selectReason = action.payload;
  return newState;
}
